import { defineStore } from 'pinia'

export interface userState {
  isLogin: boolean
  currentWallet: string | null
  userInfoObj?: any
}

export const userStore = defineStore('walletUser', {
  state: (): userState => ({
    isLogin: false, //  用户登录状态
		currentWallet: null,
		userInfoObj: {} //  用户信息
  }),
  getters: {
		getIsLogin(state): boolean {
      return state.isLogin
    },
		getUserInfoObj(state): any {
      return state.userInfoObj
    },
  },
  actions: {
    /**
		 * 保存登录状态
		 * @param {boolean} data 登录状态
		 */
		changeIsLogin(data) {
			console.log('changeIsLogin', data)
			this.isLogin = data
		},
		/**
		 * 保存用户信息
		 * @param {boolean} data 用户信息
		 */
		changeUserInfoObj(data) {
			this.userInfoObj = Object.assign({}, this.userInfoObj, data)
		},
		/**
		 * 设置当前钱包
		 * @param {String} data
		 */
		changeCurrentWallet(data) {
			this.currentWallet = data
		},
  },
})

